import cgi
import os
import logging
import base64

from collections import deque
from xml.etree import ElementTree as ET
from google.appengine.ext.webapp import template
from models import model
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
def authorization(headers):
    try:
      base = headers['authorization']
      string64 = base.split(' ')[1]
      string = base64.decodestring(string64)
      username = string.split(':')[0]
      password = string.split(':')[1]
      user = model.Users.all().filter('Screenname = ',username).filter('Password = ', password)

      if(user.count() == 0):
        return ""
      else:
        return user[0].Screenname
    except:
      return ""
